﻿using Framework.Zhaogang.Cache.Core.ConfigSection;
using Framework.Zhaogang.Utility.Core.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Framework.Zhaogang.Cache.Core
{
    /// <summary>
    /// 缓存适配器
    /// </summary>
    public class CacheAdapter
    {

        /// <summary>
        /// 获取缓存容器
        /// </summary>
        /// <param name="regionName">缓存区域名称</param>
        /// <param name="cacheProviderName"></param>
        /// <returns></returns>
        public static ICacheManager GetContainer(string regionName, string cacheProviderName = "")
        {
            var typeName = string.Format("Framework.Zhaogang.Cache.{0}", string.IsNullOrWhiteSpace(cacheProviderName) ? ConfigurationSectionHandler<CacheSettings>.Settings.CacheProviderName : cacheProviderName);
            return (ICacheManager)Activator.CreateInstance(Type.GetType(typeName));
        }
    }
}
